package io.renren.common.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.text.SimpleDateFormat;
import java.util.ResourceBundle;
import java.util.UUID;

public class CoreUtil {
	private final static Log log = LogFactory.getLog(CoreUtil.class);
	public static ResourceBundle resourceBundle = null;
	public static final String BUNDLE_KEY = "ApplicationResources";
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public static final int PUB_DIRNUM_MAX = 1000; // 发布文件夹数量最大值
	public static final String PATH_SEPARATOR = "/";
	public static final String DEPOSITORY = "depository";
	public static String DEPOSITORY_PATH = "";
	public final static String PUB_DIR_CONT = "cont";// 内容目录
	public final static String PUB_DIR_IMAGE = "image";
	public static ResourceBundle errorCodeResourceBundle = null;

	public static String getUUID() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	public static String idToPath(Long cont_Id) {
		int k = PUB_DIRNUM_MAX;// 1000
		return cont_Id / k / k / k % k + PATH_SEPARATOR + cont_Id / k / k % k + PATH_SEPARATOR + cont_Id / k % k;
	}

	public static String idToNamePath(Integer cont_Id) {
		int k = PUB_DIRNUM_MAX;// 1000
		return cont_Id / k / k / k % k + PATH_SEPARATOR + cont_Id / k / k % k + PATH_SEPARATOR + cont_Id / k % k
				+ PATH_SEPARATOR + cont_Id % k;
	}
}
